package ui;

import java.sql.Timestamp;
import java.util.Date;

/**
 * class to handle show and log messages to the user
 */
public class Logs {
	
	// Constants
	public static final String LOG_USER_LOGIN = "User logged-in";
	public static final String LOG_USER_CREATED = "User created and logged-in";
	public static final String LOG_USER_LOGIN_FAIL = "Login failed - user name doesn't exist or password entered is incorrect.";
	public static final String LOG_USER_CREATE_FAIL = "Create user failed - user name already exists";
	public static final String LOG_USER_LOGOUT = "User logged out.";
	public static final String LOG_GROUP_SELECTED = "You are now playing in group ";
	
	
	/**
	 * appends 'message' with timestamp to head of logs list
	 * @param message
	 */
	public static void append(String message) {
		// generate timestamp
		Date currTime = new java.util.Date();
		Timestamp timestamp = new Timestamp(currTime.getTime());
		String timeString = timestamp.toString().substring(0, timestamp.toString().lastIndexOf('.'));
		// append message with timestamp to head of list
		MainWindow.listLogs.add(timeString + "   :   " + message, 0);
	}
	
}
